<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 16, 2009 at 6:29:04 pm</time-stamp>
<!-- Package SupplyChain* -->


<name-space>
<name>SupplyChain</name>
<environment>Smalltalk</environment>
<private>false</private>
<imports>
			private Smalltalk.*
			</imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</name-space>

<class>
<name>Policy</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventory </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Policy</class-id>
<body>A sell policy

</body>
</comment>

<class>
<name>LastItemFirstPolicy</name>
<environment>SupplyChain</environment>
<super>SupplyChain.Policy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.LastItemFirstPolicy</class-id>
<body>A Policy which sells the last item first</body>
</comment>

<class>
<name>Item</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>name buyPrice sellPrice sku quantity reorderPoint dateRecieved </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Item</class-id>
<body>Item represents a single item of inventory in a supply chain, as purchased by a supplier, to be sold to a buy.

Instance Variables:
	buyPrice	&lt;Double&gt;	The price paid for the item by the supplier
	name	&lt;String&gt;	The name of the item
	quantity	&lt;SmallInteger&gt;	The number of item in stock
	reorderPoint	 &lt;SmallInteger&gt;	The quantity that signals the need to reorder
	sellPrice	&lt;Double&gt;	 The price a buyer pays for the item
	sku	&lt;String&gt;	The sku of a particular item

</body>
</comment>

<class>
<name>ExpensiveItemFirstPolicyTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 retailer </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.ExpensiveItemFirstPolicyTest</class-id>
<body>A test case for the ExpensiveItemFirstPolicy

Instance Variables:
	i1	&lt;Item&gt;	The cheapest item
	i2	&lt;Item&gt;	The most expensive item
	i3	&lt;Item&gt;	The earliest-arrived item
	i4	&lt;Item&gt;	The last-arrived item
	retailer	&lt;Retailer&gt;	The retailer we're trying to sell with

</body>
</comment>

<class>
<name>CCS</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>suppliers retailers allOrders </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.CCS</class-id>
<body>The central coordination system (CCS) handles the interface between all the POS locations and all the suppliers in the system.

Instance Variables:
	retailers	&lt;OrderedCollection&gt;	A list of Retailer objects
	suppliers	&lt;OrderedCollection&gt;	A list of supplier objects

</body>
</comment>

<class>
<name>RetailerEditItemDialog</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>reorderPoint sellPrice item nameAspect skuAspect </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.RetailerEditItemDialog</class-id>
<body>Retailer 

Instance Variables:
	reorderPoint	&lt;ValueHolder&gt;	description of reorderPoint
	sellPrice	&lt;ValueHolder&gt;	description of sellPrice

</body>
</comment>

<class>
<name>LotTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 i5 lot </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.LotTest</class-id>
<body>LotTest has not been commented.  The comment should state the purpose of the class and also explain any unobvious aspects of the implementation.

Instance Variables:
	i1	&lt;Object&gt;	description of i1
	i2	&lt;Object&gt;	description of i2
	i3	&lt;Object&gt;	description of i3
	i4	&lt;Object&gt;	description of i4
	i5	&lt;Object&gt;	description of i5

</body>
</comment>

<class>
<name>Supplier</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventory lots name location number </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Supplier</class-id>
<body>A Supplier.

Instance Variables:
	inventory	&lt;Inventory&gt;	Inventory if the supplier
	lots	&lt;Collection&gt;	collection of lots that make up the inventory

</body>
</comment>

<class>
<name>EarliestItemFirstPolicy</name>
<environment>SupplyChain</environment>
<super>SupplyChain.Policy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.EarliestItemFirstPolicy</class-id>
<body>A Policy sells that the earliest item first

</body>
</comment>

<class>
<name>LastItemFirstPolicyTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 retailer </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.LastItemFirstPolicyTest</class-id>
<body>A test case for the LastItemFirstPolicy

Instance Variables:
	i1	&lt;Item&gt;	The cheapest item
	i2	&lt;Item&gt;	The most expensive item
	i3	&lt;Item&gt;	The earliest-arrived item
	i4	&lt;Item&gt;	The last-arrived item
	retailer	&lt;Retailer&gt;	The retailer we're trying to sell with
</body>
</comment>

<class>
<name>Inventory</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>items </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Inventory</class-id>
<body>Thiss class represents an inventory of items

Instance Variables:
	items	&lt;SortedCollection&gt;	A sorted collection of items in the inventory

</body>
</comment>

<class>
<name>InvoiceTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>items i1 i2 i3 i4 i5 invoice </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.InvoiceTest</class-id>
<body>Tests the capability of the invoice to hold items.

Instance Variables:
	i1	&lt;Object&gt;	a test Item
	i2	&lt;Object&gt;	a test Item
	i3	&lt;Object&gt;	a test Item
	i4	&lt;Object&gt;	a test Item
	i5	&lt;Object&gt;	a test Item
	invoice	&lt;Invoice&gt;	a test invoice
	items	&lt;SortedCollection&gt;	a list of items to insert into the invoice

</body>
</comment>

<class>
<name>SupplierOutstandingInvoicesDialog</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>invoiceList model </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog</class-id>
<body>model: aModel

	model:= aModel.
	^self</body>
</comment>

<class>
<name>EmergencyOrderReport</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>data orders </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.EmergencyOrderReport</class-id>
<body>SupplierQuantityReport shows a bar chart of quantities of items provided for a specific Item/Supplier by POS Location.

Instance Variables:
	Chart1	&lt;ValueHolder&gt;	A Bar Chart
	retailers	&lt;OrderedCollection&gt;A list of retailers
	suppliers	&lt;OrderedCollection&gt;	 A list of suppliers

</body>
</comment>

<class>
<name>RetailerSellPolicyDialog</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>policiesAspect </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.RetailerSellPolicyDialog</class-id>
<body>I am a dialog for displaying and changing the sell policies or the retailer.

Not really Instance Variables:
	policy &lt;SellPolicy class&gt;	Gets or sets the SellPolicy that is/was selected.</body>
</comment>

<class>
<name>SupplierTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>supplier i1 i2 i3 i4 i5 inventory itemList i6 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.SupplierTest</class-id>
<body>Tester for the supplier class

Instance Variables:
	i1	&lt;Item&gt; a test item instance
	i2	&lt;Item&gt;	a test item instance
	i3	&lt;Item&gt;	a test item instance
	i4	&lt;Item&gt;	a test item instance
	i5	&lt;Item&gt;	a test item instance
	inventory	&lt;Inventory&gt;	an instance of the inventory to seed the supplier with
	supplier       &lt;Supplier&gt; an instance of the suppier to test.
</body>
</comment>

<class>
<name>RetailerAppModel</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>reorderPoint currentInventoryList inventoryList retailer currentOrder itemList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.RetailerAppModel</class-id>
<body>Main GUI for Retailer, contains list of inventory, items on order...

Instance Variables:
	retailer	&lt;Retailer&gt;					the retailer this is controlling
	currentOrder	&lt;Order&gt;			the current/next order which will be sent
	inventoryList	&lt;SelectionInList&gt;	list of inventory items
	itemList	&lt;SelectionInList&gt;			list of items on the order</body>
</comment>

<class>
<name>CheapestItemFirstPolicyTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 retailer </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id>
<body>A test case for the CheapestItemFirstPolicy

Instance Variables:
	i1	&lt;Item&gt;	The cheapest item
	i2	&lt;Item&gt;	The most expensive item
	i3	&lt;Item&gt;	The earliest-arrived item
	i4	&lt;Item&gt;	The last-arrived item
	retailer	&lt;Retailer&gt;	The retailer we're trying to sell with

</body>
</comment>

<class>
<name>SupplierNewLotDialog</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>lotNum price itemList model inventory </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.SupplierNewLotDialog</class-id>
<body>SupplierNewLotDialog holds list of items supplier has, lot number of the item, price of item an an option to add to lot. 

Instance Variables:
	itemList	&lt;SelectionInList&gt;	list of items
	lotNum	&lt;ValueHolder&gt;	lot number of item
	price	&lt;ValueHolder&gt;	price of item

</body>
</comment>

<class>
<name>Invoice</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>itemList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Invoice</class-id>
<body>An ordered collection of items to be reordered.
Instance Variables:
	itemList	&lt;Object&gt;	An Ordered Collection of Items

</body>
</comment>

<class>
<name>EarliestItemFirstPolicyTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 retailer </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.EarliestItemFirstPolicyTest</class-id>
<body>A test case for the EarliestItemFirstPolicy

Instance Variables:
	i1	&lt;Item&gt;	The cheapest item
	i2	&lt;Item&gt;	The most expensive item
	i3	&lt;Item&gt;	The earliest-arrived item
	i4	&lt;Item&gt;	The last-arrived item
	retailer	&lt;Retailer&gt;	The retailer we're trying to sell with
</body>
</comment>

<class>
<name>OrderTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>order </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.OrderTest</class-id>
<body>This is an SUnit test class for the Order Class

Instance Variables:
	order	&lt;Order&gt;	An Instance of the Order class

</body>
</comment>

<class>
<name>RetailerTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 i5 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.RetailerTest</class-id>
<body>RetailerTest has not been commented.  The comment should state the purpose of the class and also explain any unobvious aspects of the implementation.

Instance Variables:
	i1	&lt;Item&gt;	an item in the retailer
	i2	&lt;Item&gt;	an item in the retailer
	i3	&lt;Item&gt;	an item in the retailer
	i4	&lt;Item&gt;	an item in the retailer
	i5	&lt;Item&gt;	an item in the retailer

</body>
</comment>

<class>
<name>SupplierAppModel</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventoryList itemList invoiceList lotNum price model </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.SupplierAppModel</class-id>
<body>SupplierAppModel holds the supplier's inventory, an option to create lots, view reports and outstanding invoices. 

Instance Variables:
	inventoryList	&lt;Object&gt;	list of supplier's inventory 
	invoiceList	&lt;Object&gt;	show's supplier's invoice 
	itemList	&lt;Object&gt;	list of items
	lotNum	&lt;Object&gt;	lot number of item
	price	&lt;Object&gt;	price of item

</body>
</comment>

<class>
<name>ExpensiveItemFirstPolicy</name>
<environment>SupplyChain</environment>
<super>SupplyChain.Policy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id>
<body>A Policy which sells the most expensive item first

</body>
</comment>

<class>
<name>CCSAppModel</name>
<environment>SupplyChain</environment>
<super>UI.ApplicationModel</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>ccs retailerList supplierList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.CCSAppModel</class-id>
<body>GUI with list of retailers and suppliers. You can add/delete suppliers/retailers and view inventory

Instance Variables:
	ccs &lt;CCS&gt; A CCS
	retailerList	&lt;SelectionInList&gt;	list of retailers
	supplierList	&lt;SelectionInList&gt;	description of supplierList

</body>
</comment>

<class>
<name>CheapestItemFirstPolicy</name>
<environment>SupplyChain</environment>
<super>SupplyChain.Policy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.CheapestItemFirstPolicy</class-id>
<body>A SellPolicy which sells the cheapest item first

</body>
</comment>

<class>
<name>Order</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>items priority retailer filled </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Order</class-id>
<body>This represents a lists of items with a priority as requested of a Supplier

Instance Variables:
	items	&lt;OrderedCollection&gt;	 The list of items being requested
	priority	&lt;Boolean&gt;	The priority of the order, true if high

</body>
</comment>

<class>
<name>CCSTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>ccs r1 r2 s1 s2 i1 i2 l1 l2 it1 it2 it3 it4 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.CCSTest</class-id>
<body>This is an SUnit test class for the CCS Class

Instance Variables:
	ccs	&lt;CCS&gt;	A CCS Instance to run tests on

</body>
</comment>

<class>
<name>SupplierQuantityReport</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>suppliers retailers data </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.SupplierQuantityReport</class-id>
<body>SupplierQuantityReport shows a bar chart of quantities of items provided for a specific Item/Supplier by POS Location.

Instance Variables:
	Chart1	&lt;ValueHolder&gt;	A Bar Chart
	retailers	&lt;OrderedCollection&gt;A list of retailers
	suppliers	&lt;OrderedCollection&gt;	 A list of suppliers

</body>
</comment>

<class>
<name>ItemTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.ItemTest</class-id>
<body>A test class for the SUnit testing the Item class

Instance Variables:
	i1	&lt;Item&gt;	An item

</body>
</comment>

<class>
<name>Lot</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>number itemList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Lot</class-id>
<body>A lot tracks a specific set of items which are all sold at a price point.

Instance Variables:
	itemList	&lt;Collection&gt;	a collection of items
	number	&lt;LargeInteger&gt;	the ID number of this lot

</body>
</comment>

<class>
<name>Retailer</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location number sellPolicy inventory ccs name lastOrderPlaced </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.Retailer</class-id>
<body>A specific outlet store or other point-of-sale location.

Instance Variables:
	location	&lt;String&gt;	The location of the store
	number	&lt;Integer&gt;	The store's ID number
	sellPolicy	&lt;Policy&gt;	The policy this store sells items with

</body>
</comment>

<class>
<name>InventoryTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventory i1 i2 i3 i4 i5 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.InventoryTest</class-id>
<body>This is the provided test class for M1.  You should not need to edit the class yourself.

To run, either install the RBSunit extension parcel and run from the system browser OR

highlight this code

TestRunner open

and doit.

Instance Variables:
	i1	&lt;Item&gt; a test item instance
	i2	&lt;Item&gt;	a test item instance
	i3	&lt;Item&gt;	a test item instance
	i4	&lt;Item&gt;	a test item instance
	i5	&lt;Item&gt;	a test item instance
	inventory	&lt;Inventory&gt;	an instance of the inventory class for test

</body>
</comment>

<class>
<name>ItemPriceVoltilityReport</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>data orders item </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.ItemPriceVoltilityReport</class-id>
<body>SupplierQuantityReport shows a bar chart of quantities of items provided for a specific Item/Supplier by POS Location.

Instance Variables:
	Chart1	&lt;ValueHolder&gt;	A Bar Chart
	retailers	&lt;OrderedCollection&gt;A list of retailers
	suppliers	&lt;OrderedCollection&gt;	 A list of suppliers

</body>
</comment>





































<methods>
<class-id>SupplyChain.Lot class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Lot</class-id> <category>accessing</category>

<body package="SupplyChain" selector="number">number
	^number</body>

<body package="SupplyChain" selector="itemList">itemList
	^itemList</body>

<body package="SupplyChain" selector="remove:">remove: anItem
	"Removes an item from the Lot"

	^itemList remove: anItem</body>

<body package="SupplyChain" selector="addItem:">addItem: anItem
	"Adds an item to the list"

	itemList add: anItem.
	^self</body>

<body package="SupplyChain" selector="size">size
	"How many items are in this lot?"

	^itemList size</body>

<body package="SupplyChain" selector="contains:">contains: anItem
	"Tests if Lot contains an item"

	^itemList contains: [ :i | anItem sku = i sku].</body>

<body package="SupplyChain" selector="number:">number: aLargeInteger
	number := aLargeInteger</body>
</methods>

<methods>
<class-id>SupplyChain.Lot</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	number := 0.
	itemList := OrderedCollection new.

	^self</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerSellPolicyDialog class</class-id> <category>creating </category>

<body package="SupplyChain" selector="showGetSellPolicy:">showGetSellPolicy: aSellPolicy
	"I open a new window and select a given SellPolicy.  You can click on my buttons to select a new SellPolicy.  If you click Change, I will return the SellPolicy class
	you selected.  If you click Cancel, I will be very sad but I will return the SellPolicy class that you originally passed as a parameter."
	
	| window |
	window := self new initialize.
	window policy: aSellPolicy.
	^window open
		ifTrue: [ ^window policy. ]
		ifFalse: [ ^aSellPolicy. ]</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerSellPolicyDialog class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#properties: #(#{UI.PropertyListDictionary} #openType #userPlacement ) 
			#label: 'Retailer Sell Policy GUI' 
			#min: #(#{Core.Point} 20 20 ) 
			#max: #(#{Core.Point} 0 0 ) 
			#bounds: #(#{Graphics.Rectangle} 640 512 950 692 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 12 33 295 136 ) 
					#name: #List1 
					#model: #policiesAspect 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 12 6 ) 
					#name: #Label1 
					#label: 'Select a sell policy' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 52 149 133 172 ) 
					#name: #ActionButton1 
					#model: #accept 
					#label: 'Ch&amp;ange' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 165 151 246 174 ) 
					#name: #ActionButton2 
					#model: #cancel 
					#label: '&amp;Cancel' 
					#defaultable: true ) ) ) )</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerSellPolicyDialog</class-id> <category>aspects</category>

<body package="SupplyChain" selector="policiesAspect">policiesAspect
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^policiesAspect isNil
		ifTrue:
			[policiesAspect := SelectionInList new]
		ifFalse:
			[policiesAspect]</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerSellPolicyDialog</class-id> <category>accessing</category>

<body package="SupplyChain" selector="policy:">"I set the currently selected policy."

policy: aSellPolicy
	policiesAspect selection: aSellPolicy</body>

<body package="SupplyChain" selector="policy">"I get the currently selected policy."

policy
	^policiesAspect selection.</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerSellPolicyDialog</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."
	
	| policies |
	policies := OrderedCollection new.
	policies add: CheapestItemFirstPolicy.
	policies add: EarliestItemFirstPolicy.
	policies add: ExpensiveItemFirstPolicy.
	policies add: LastItemFirstPolicy.
	super initialize.
	(policiesAspect := SelectionInList new) listHolder: (UI.ValueHolder with: policies).
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.CCS class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.CCS</class-id> <category>updating</category>

<body package="SupplyChain" selector="updateWith:">updateWith: aCCS
	"Used with BOSS loading to update a newly loaded class instance
	This method is to be used by the AppModel, not the GUI itself. Ignore
	it for now"
	retailers size timesRepeat: [ retailers removeFirst ].
	suppliers size timesRepeat: [ suppliers removeFirst ].
	aCCS retailers do: [ :r | self addRetailer: r.].
	aCCS suppliers do: [ :s | self addSupplier: s.].
	^self.</body>

<body package="SupplyChain" selector="deepCopy">deepCopy
	"Returns a deep copy of the current CCS object instance"
	|ccs|
	ccs := CCS new.
	self retailers do: [ :r | ccs addRetailer: r.].
	self suppliers do: [ :s | ccs addSupplier: s.].
	^ccs.</body>

<body package="SupplyChain" selector="removeRetailer:">removeRetailer: aRetailer
	"Remove a retailer"
	(retailers includes: aRetailer) ifTrue:[
		aRetailer ccs: nil.
		retailers remove: aRetailer.].
	^self.</body>

<body package="SupplyChain" selector="addRetailer:">addRetailer: aRetailer
	"Add a retaiier"
	aRetailer ccs: self.
	retailers add: aRetailer.
	^self.</body>

<body package="SupplyChain" selector="removeSupplier:">removeSupplier: aSupplier
	"Remove a supplier"
	(suppliers includes: aSupplier) ifTrue:[ suppliers remove: aSupplier.].
	^self.</body>

<body package="SupplyChain" selector="addSupplier:">addSupplier: aSupplier
	"Add a supplier"
	suppliers add: aSupplier.
	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.CCS</class-id> <category>accessing</category>

<body package="SupplyChain" selector="retailers">retailers
	^retailers</body>

<body package="SupplyChain" selector="retailers:">retailers: anObject
	retailers := anObject</body>

<body package="SupplyChain" selector="suppliers:">suppliers: anObject
	suppliers := anObject</body>

<body package="SupplyChain" selector="allOrders">allOrders
	^allOrders.</body>

<body package="SupplyChain" selector="suppliers">suppliers
	^suppliers</body>
</methods>

<methods>
<class-id>SupplyChain.CCS</class-id> <category>load-save</category>

<body package="SupplyChain" selector="load">load
	"Load a previous state"
	|boss filename array ccs|
	filename := Dialog requestFileName: 'Open CCS'.
	(filename = '') ifFalse:[
		boss := BinaryObjectStorage onOldNoScan: filename asFilename readStream.
		[array := boss contents] ensure: [boss close].
		ccs := array at: 1.
		self updateWith: ccs.
	].
	^self.</body>

<body package="SupplyChain" selector="save">save
	"Save the current CCS"
	|boss filename ccs|
	ccs := self deepCopy.
	filename := Dialog requestFileName: 'Open CCS'.
	(filename = '') ifFalse:[
		boss := BinaryObjectStorage onNew: filename asFilename writeStream.
		[boss nextPut: ccs ] ensure: [boss close].
	].
	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.CCS</class-id> <category>coordinating</category>

<body package="SupplyChain" selector="handleOrder:">handleOrder: anOrder
	"Handles a single order from a Retailer"
	|d invoices|
	d := Dictionary new.
	invoices := OrderedCollection new.
	allOrders add: anOrder.
	(anOrder items) do: [ :item | | supplier |
     		supplier := suppliers detect: [ :s | s sellItem: item].
     		(d includesKey: supplier) ifFalse: [ d add: (Association key: supplier value: (OrderedCollection new)).].
    		(d at: supplier) add: item.].

	d associations do: [:a | invoices add: ((a key) orderItems: (a value)).]. 

	(anOrder retailer) shipmentArrived: invoices.
	anOrder filled: true.
	^self.

	"(anOrder items) do:[:i|
		suppliers do:[:j|
			(j sellsItem: i) ifTrue:[
				(neededSuppliers includes: j) 
			ifFalse:[
				neededSuppliers add: j.].].].].

	neededSuppliers do:[:i| 
		(anOrder items) do:[:j| (i sellsItem: j) ifTrue:[itemsToInvoice add: j.].].
		invoices add: (i orderItems: itemsToInvoice).
		itemsToInvoice := OrderedCollection new.]."</body>
</methods>

<methods>
<class-id>SupplyChain.CCS</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	suppliers := OrderedCollection new.
	retailers := OrderedCollection new.
	allOrders := OrderedCollection new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.EmergencyOrderReport class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 
			#(#{Kernel.UserMessage} 
				#key: #EasyChart2 
				#defaultString: 'Supplier Quantity Report' 
				#catalogID: #BGOK ) 
			#min: #(#{Core.Point} 20 20 ) 
			#bounds: #(#{Graphics.Rectangle} 640 512 905 703 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.ChartViewSpec} 
					#layout: #(#{Graphics.LayoutFrame} 5 0 5 0 -5 1 -5 1 ) 
					#model: #data 
					#chartType: #BG_PieChartView 
					#dataSeries: 
					#(#{UI.ChartDataSpec} 
						#series: #(
							#(#{UI.ChartDataSetSpec} 
								#name: 'Data1' ) 
							#(#{UI.ChartDataSetSpec} 
								#isData: false 
								#name: 'Labels' ) ) ) 
					#yAxis: 
					#(#{UI.ChartingValueAxisSpec} 
						#scale: 
						#(#{UI.ChartingScaleSpec} 
							#invert: true 
							#restrictions: #(#auto ) ) ) ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.EmergencyOrderReport class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize.</body>
</methods>


<methods>
<class-id>SupplyChain.EmergencyOrderReport</class-id> <category>aspects</category>

<body package="SupplyChain" selector="data">data

	| normal priority inner outer inner2 |

	normal:= 0.	" counter for normal priority answers	"
	priority:= 0.  " counter for high priority answers	"
	outer:= OrderedCollection new.
	orders do: [:i |
		i priority ifFalse: [
			normal:= normal + 1.
		].
		i priority ifTrue:[
			priority:= priority + 1.
		].
	].
	inner:= OrderedCollection new.
	inner add: normal.
	inner add: 'Normal Priority'.
	
	inner2:= OrderedCollection new.
	inner2 add: priority.
	inner2 add: 'High Priority'.

	outer add: inner.
	outer add: inner2.

	^outer.</body>
</methods>

<methods>
<class-id>SupplyChain.EmergencyOrderReport</class-id> <category>accessing</category>

<body package="SupplyChain" selector="orders">orders

	^orders</body>

<body package="SupplyChain" selector="orders:">orders: anObject

	orders := anObject.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.EmergencyOrderReport</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	orders := OrderedCollection new.
	
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.InventoryTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i5:">i5: anObject
	i5 := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="inventory:">inventory: anObject
	inventory := anObject</body>

<body package="SupplyChain" selector="i5">i5
	^i5</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="inventory">inventory
	^inventory</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testInventoryValue">testInventoryValue
   self setUpPrices.
   self assert: inventory inventoryValue = 634.</body>

<body package="SupplyChain" selector="testInventoryPrintString">testInventoryPrintString
   self setUpPrices.
   self assert: inventory printString = 'An Inventory of 5 items valued at 634 dollars'.</body>

<body package="SupplyChain" selector="setUp">setUp
   "Create test objects.  This is called before every individual test"
   inventory := Inventory new.
   i1 := Item named: 'Video Game' sku:'89X999'.
   i2 := Item named: 'TV' sku: '99Z837'.
   i3 := Item named: 'VCR' sku: '54Y3632'.
   i4 := Item named: 'PC' sku: '01P6373'.
   i5 := Item named: 'Laptop' sku: '11F4732'.</body>

<body package="SupplyChain" selector="testInventoryPotentialProfit">testInventoryPotentialProfit
   self setUpPrices.
   Transcript show: inventory potentialProfit printString.
   self assert: inventory potentialProfit = 442.</body>

<body package="SupplyChain" selector="testGetReorderItems">testGetReorderItems
   | coll |
   self setUpPrices.
   coll := inventory getReorderItems.
   self assert: coll size = 2.
   self assert: (coll includes: i1).
   self assert: (coll includes: i4).</body>

<body package="SupplyChain" selector="testInventoryPrintInventoryReport">testInventoryPrintInventoryReport
   self setUpPrices.
   inventory printInventoryReport</body>

<body package="SupplyChain" selector="testInventorySortBlock">testInventorySortBlock
   self addAllItems.
   self assert: (inventory items at: 1) = i5.
   self assert: (inventory items at: 5) = i1.
   inventory sortBlock: [ :a :b | a sku &lt; b sku].
  self assert: (inventory items at: 1) = i4.
  self assert: (inventory items at: 5) = i2.</body>

<body package="SupplyChain" selector="testInventoryAddItem">testInventoryAddItem
     self assert: inventory items size = 0.
     inventory addItem: i1.
    self assert: inventory items size = 1.
    self assert: (inventory items includes: i1).
    inventory addItem: i2.
    self assert: inventory items size = 2.
    self assert: (inventory items includes: i2).</body>

<body package="SupplyChain" selector="testGetInventoryCost">testGetInventoryCost
   self setUpPrices.
   self assert: inventory getInventoryCost = 86.</body>

<body package="SupplyChain" selector="testInventoryRemoveItem">testInventoryRemoveItem
    self addAllItems.
    self assert: (inventory items includes: i3).
    inventory removeItem: i3.
    self deny: (inventory items includes: i3).</body>

<body package="SupplyChain" selector="testGetInventoryValue">testGetInventoryValue
   self setUpPrices.
   self assert: inventory getInventoryValue = 634.</body>
</methods>

<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   self addAllItems.
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.
   i2 buyPrice: 22.
   i2 sellPrice: 36.
   i2 quantity: 7.
   i2 reorderPoint: 6.
   i3 buyPrice: 18.
   i3 sellPrice: 40.
   i3 quantity: 3.
   i3 reorderPoint: 3.
   i4 buyPrice: 19.
   i4 sellPrice: 36.
   i4 quantity: 6.
   i4 reorderPoint: 7.
   i5 buyPrice: 24.
   i5 sellPrice: 36.
   i5 quantity: 12.
   i5 reorderPoint: 10.</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	inventory := nil.
	i1 := nil.
	i2 := nil.
	i3 := nil.
	i4 := nil.
	i5 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventory"
   inventory addItem: i1.
   inventory addItem: i2.
  inventory addItem: i3.
  inventory addItem: i4.
  inventory addItem: i5.</body>
</methods>


<methods>
<class-id>SupplyChain.Invoice class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Invoice</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	itemList := SortedCollection new.
	itemList sortBlock:[:a :b | a name &lt; b name].
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Invoice</class-id> <category>accessing</category>

<body package="SupplyChain" selector="itemList">itemList

	^itemList</body>

<body package="SupplyChain" selector="itemList:">itemList: aList

	itemList := aList.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Invoice</class-id> <category>required</category>

<body package="SupplyChain" selector="getInvoiceCost">getInvoiceCost

	| sum | 
	sum := 0.
	self itemList do: [:i | sum := sum + i buyPrice ].
	^sum</body>

<body package="SupplyChain" selector="getInvoiceValue">getInvoiceValue

	| sum |
	sum := 0.
	self itemList do: [:i | sum := sum + i itemValue ].
	^sum</body>

<body package="SupplyChain" selector="addItem:">addItem: anItem

	self itemList add: anItem.
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierAppModel class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Supplier Main GUI' 
			#bounds: #(#{Graphics.Rectangle} 640 512 951 785 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 4 250 ) 
					#name: #supplierGUI 
					#label: 'Supplier Main GUI' ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 16 58 156 226 ) 
					#name: #inventoryList 
					#model: #inventoryList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 19 32 ) 
					#name: #supplierInventory 
					#label: 'Supplier Inventory' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 186 166 267 189 ) 
					#name: #createLot 
					#model: #createLotClick 
					#label: 'Create Lot' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 171 89 291 112 ) 
					#name: #outstandingInvoices 
					#model: #outstandingInvoicesClick 
					#label: 'Outstanding Invoices' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 108 239 189 262 ) 
					#name: #accept 
					#model: #accept 
					#label: 'Done' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 208 238 289 261 ) 
					#name: #cancel 
					#model: #cancel 
					#label: 'Cancel' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierAppModel class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierAppModel</class-id> <category>aspects</category>

<body package="SupplyChain" selector="inventoryList">inventoryList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^inventoryList isNil
		ifTrue:
			[inventoryList := SelectionInList new]
		ifFalse:
			[inventoryList]</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierAppModel</class-id> <category>accessing</category>

<body package="SupplyChain" selector="model:">model: aSupplier

	model:= aSupplier.
      (inventoryList:= SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (model inventory) sendsUpdates: true)forAspect: #items).
	^self</body>

<body package="SupplyChain" selector="model">model

	^model</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierAppModel</class-id> <category>actions</category>

<body package="SupplyChain" selector="outstandingInvoicesClick">outstandingInvoicesClick

	"This stub method was generated by UIDefiner"

	SupplierOutstandingInvoicesDialog open.
	^self</body>

<body package="SupplyChain" selector="createLotClick">createLotClick	
	"This stub method was generated by UIDefiner"
	" opens the Gui dialog to create a new lot	"
	|gui 	|
	
	gui:= SupplierNewLotDialog new.
	"set the appModel's data to the current selection	"
	gui model: model inventory.	
	"copy the supplier's current inventory to the temp inventory"

	
	gui open.

	self changed: #inventory.
	^self</body>

<body package="SupplyChain" selector="createLot">createLot

	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="outstandingInvoices">outstandingInvoices

	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="viewReports">viewReports

	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="viewReportsClick">viewReportsClick

	"This stub method was generated by UIDefiner"

	^self</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierAppModel</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
   super initialize.
   "Make the instance of our domain model.  We make model an instance variable so we can use it in other methods."
   model := Supplier new.
   
   "now we set up the list box for inventory.  We set the model of the list box to be a selectable item"
    
    (inventoryList:= SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (model inventory) sendsUpdates: true)forAspect: #items).

	^self</body>
</methods>


<methods>
<class-id>SupplyChain.Supplier class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Supplier</class-id> <category>accessing</category>

<body package="SupplyChain" selector="location:">location: anObject
	location := anObject.</body>

<body package="SupplyChain" selector="lots">lots

	^lots.
</body>

<body package="SupplyChain" selector="inventory">inventory
	
	^inventory</body>

<body package="SupplyChain" selector="number">number

	^number</body>

<body package="SupplyChain" selector="number:">number: aNumber
	
	number:= aNumber.
	^self</body>

<body package="SupplyChain" selector="name">name

	^name</body>

<body package="SupplyChain" selector="inventory:">inventory: anInventory
	
	inventory := anInventory.
	^self</body>

<body package="SupplyChain" selector="location">location
	^location.</body>

<body package="SupplyChain" selector="lots:">lots: aLot
	
	lots:= aLot.
	^self</body>

<body package="SupplyChain" selector="name:">name: aName
	
	name:= aName.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>selling-ordering</category>

<body package="SupplyChain" selector="sellItem:">sellItem: anItem
	"takes in an Item and returns a Boolean if the supplier sells that type of Item. (i.e. it is in its inventory)"
	
	^inventory items anySatisfy: [:i | (i sku = anItem sku).].</body>

<body package="SupplyChain" selector="createLot:">createLot: newLot

	lots add: newLot.

	^self</body>

<body package="SupplyChain" selector="orderItems:">orderItems: items
	"takes in an Ordered Collection of items, makes an invoice for those items, updates with the newest information based on the Supplier (i.e. buyPrice, sellPrice, lotNumber, etc...), and returns the invoice containing the requested Items. "

	| invoice item updatedList temp |

	updatedList := OrderedCollection new.
	invoice:= Invoice new.
	

	items do:[:i | 
		item:= inventory items detect: [:a | a name = i name ].
		temp := item quantity.
		item quantity: i quantity.
		updatedList add: item.
		inventory items remove: item.
		item quantity: (temp - i quantity).
		inventory items add: item.
	].
	
	invoice itemList: updatedList.
	^invoice</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>printing</category>

<body package="SupplyChain" selector="printString">printString
	^(name,' ', location, ' ', number).</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	lots := OrderedCollection new.
	inventory:= Inventory new.
	"inventory sortBlock:[:a :b | a lotNumber &lt; b lotNumber]."
	name:= 'Default'.
	location := 'Place'.
	number := nil.

	^self</body>
</methods>


<methods>
<class-id>SupplyChain.LastItemFirstPolicyTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.LastItemFirstPolicyTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="retailer">retailer
	^retailer</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="retailer:">retailer: anObject
	retailer := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.LastItemFirstPolicyTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testLastItem">testLastItem
	"Tests that the last item (i4) is selected to sell"

	| soldItem |
	soldItem := retailer sellItem: i1.
	self assert: (soldItem == i4).</body>
</methods>

<methods>
<class-id>SupplyChain.LastItemFirstPolicyTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	| inventory |
	inventory := Inventory new.
	i1 := Item named: 'Taco' sku: '123456'.
	i1 quantity: 10.
	i1 buyPrice: 8.
	i1 dateRecieved: (Date newDay: 4 monthNumber: 6 year: 2008).
	inventory addItem: i1.
	i2 := Item named: 'Taco' sku: '123456'.
	i2 quantity: 10.
	i2 buyPrice: 20.
	i2 dateRecieved: (Date newDay: 5 monthNumber: 7 year: 2008).
	inventory addItem: i2.
	i3 := Item named: 'Taco' sku: '123456'.
	i3 quantity: 10.
	i3 buyPrice: 10.
	i3 dateRecieved: (Date newDay: 10 monthNumber: 2 year: 2008).
	inventory addItem: i3.
	i4 := Item named: 'Taco' sku: '123456'.
	i4 quantity: 10.
	i4 buyPrice: 11.
	i4 dateRecieved: (Date newDay: 1 monthNumber: 10 year: 2008).
	inventory addItem: i4.
	
	retailer := Retailer new.
	retailer inventory: inventory.
	retailer sellPolicy: LastItemFirstPolicy new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.Order class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Order</class-id> <category>updating</category>

<body package="SupplyChain" selector="filled">filled
	^filled.</body>

<body package="SupplyChain" selector="remove:">remove: anItem
	"Removes an item from the list of items"
	items remove: anItem.
	^self.</body>

<body package="SupplyChain" selector="filled:">filled: aBoolean
	filled := aBoolean.
	^self.</body>

<body package="SupplyChain" selector="add:">add: anItem
	"Adds an item to the list"
	items add: anItem.
	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.Order</class-id> <category>accessing</category>

<body package="SupplyChain" selector="priority:">priority: anObject
	priority := anObject</body>

<body package="SupplyChain" selector="contains:">contains: anItem
	"Checks whether the list of items contains an item"
	^(items includes: anItem).</body>

<body package="SupplyChain" selector="retailer">retailer
	^retailer.</body>

<body package="SupplyChain" selector="items:">items: anObject
	items := anObject</body>

<body package="SupplyChain" selector="priority">priority
	^priority</body>

<body package="SupplyChain" selector="retailer:">retailer: anObject
	retailer := anObject.</body>

<body package="SupplyChain" selector="items">items
	^items</body>
</methods>

<methods>
<class-id>SupplyChain.Order</class-id> <category>prioritizing</category>

<body package="SupplyChain" selector="setPriority:">setPriority: aBoolean
	"Sets the priority of the Order, high if true"
	priority := aBoolean.
	^self.</body>

<body package="SupplyChain" selector="isHighPriority">isHighPriority
	"Returns true if the Order has high priority"
	^priority.</body>
</methods>

<methods>
<class-id>SupplyChain.Order</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	items := OrderedCollection new.
	priority := false.
	retailer := nil.
	filled := false.
	" *** And replace this comment with additional initialization code *** "
	^self</body>

<body package="SupplyChain" selector="with:atHighPriority:by:">with: aCollection atHighPriority: aBoolean by: aRetailer
	"Creates an order with a collection and a specified priority"
	items := aCollection.
	priority := aBoolean.
	retailer := aRetailer.
	^self.</body>
</methods>


<methods>
<class-id>SupplyChain.Policy class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="withInventory:">withInventory: anInventory
	| policy |
	policy := Policy new.
	policy inventory: anInventory.
	^policy.</body>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Policy</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory">inventory
	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: anObject
	inventory := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.Policy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	"comment stating purpose of message"
	self subclassResponsibility</body>
</methods>

<methods>
<class-id>SupplyChain.Policy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Replace this comment with the appropriate initialization code *** "
	inventory = Inventory new.
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.CheapestItemFirstPolicy</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory">inventory
	^inventory</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	" *** This method was defined by SupplyChain.Policy as a subclass responsibility.
	Replace its body with a proper implementation. *** "

	| cheapest items |
	"pick the items with this SKU"
	"SELECT * INTO item FROM inventory WHERE NOT EXISTS (SELECT * INTO i FROM inventory WHERE (i != item) AND (item.sellPrice &gt; i.sellPrice))"
	items := (self inventory items) select: [ :i | i sku = anSku ].
	cheapest := items first.
	items do:
		[ :item |
		(item buyPrice &lt; cheapest buyPrice)
			ifTrue: [ cheapest := item. ]
		].
	^cheapest.</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i2:">i2: anItem
	
	i2 := anItem.
	^self</body>

<body package="SupplyChain" selector="supplier">supplier

	^supplier</body>

<body package="SupplyChain" selector="i4:">i4: anItem
	
	i4 := anItem.
	^self</body>

<body package="SupplyChain" selector="inventory">inventory

	^inventory</body>

<body package="SupplyChain" selector="i6:">i6: anItem
	
	i6 := anItem.
	^self</body>

<body package="SupplyChain" selector="i6">i6

	^i6</body>

<body package="SupplyChain" selector="i3:">i3: anItem
	
	i3 := anItem.
	^self</body>

<body package="SupplyChain" selector="i5">i5
	
	^i5</body>

<body package="SupplyChain" selector="i3">i3
	
	^i3</body>

<body package="SupplyChain" selector="supplier:">supplier: aSupplier

	supplier:= aSupplier.
	
	^self</body>

<body package="SupplyChain" selector="inventory:">inventory: anInventory

	inventory := anInventory.
	^self</body>

<body package="SupplyChain" selector="i4">i4
	
	^i4</body>

<body package="SupplyChain" selector="i2">i2
	
	^i2</body>

<body package="SupplyChain" selector="itemList:">itemList: aList
	
	itemList:= aList.
	^self</body>

<body package="SupplyChain" selector="i5:">i5: anItem
	
	i5 := anItem.
	^self</body>

<body package="SupplyChain" selector="i1:">i1: anItem
	
	i1 := anItem.
	^self</body>

<body package="SupplyChain" selector="itemList">itemList
	
	^itemList</body>

<body package="SupplyChain" selector="i1">i1
	
	^i1</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">
setUp
   "Create test objects.  This is called before every individual test"
   inventory := Inventory new.
   supplier:= Supplier new.

   i1 := Item named: 'Video Game' sku:'89X999'.
   i2 := Item named: 'TV' sku: '99Z837'.
   i3 := Item named: 'VCR' sku: '54Y3632'.
   i4 := Item named: 'PC' sku: '01P6373'.
   i5 := Item named: 'Laptop' sku: '11F4732'.
   i6 := Item named: 'DVD' sku: '11F2374'.

   self setUpPrices.
   self addAllItems.

   supplier inventory: inventory.</body>

<body package="SupplyChain" selector="testOrderItems">testOrderItems

	| tempInvoice	|

      self setUpPrices.
   	self addAllItems.
	

	itemList add: i1.
      itemList add: i4.


	tempInvoice:= supplier orderItems: itemList.

	

	self assert: tempInvoice itemList size = 2.
      self assert: (tempInvoice itemList includes: i1).
	self assert: (tempInvoice itemList includes: i4).</body>

<body package="SupplyChain" selector="testSellItem">testSellItem

	self assert: (supplier sellItem: i3).
	
	self deny: (supplier sellItem: i6).</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventory"
   inventory addItem: i1.
   inventory addItem: i2.
   inventory addItem: i3.
   inventory addItem: i4.
   inventory addItem: i5.

</body>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   self addAllItems.
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.
   i1 lotNumber: 12.
   i2 buyPrice: 22.
   i2 sellPrice: 36.
   i2 quantity: 7.
   i2 reorderPoint: 6.
   i2 lotNumber: 5.
   i3 buyPrice: 18.
   i3 sellPrice: 40.
   i3 quantity: 3.
   i3 reorderPoint: 3.
   i3 lotNumber: 2.
   i4 buyPrice: 19.
   i4 sellPrice: 36.
   i4 quantity: 6.
   i4 reorderPoint: 7.
   i4 lotNumber: 54.
   i5 buyPrice: 24.
   i5 sellPrice: 36.
   i5 quantity: 12.
   i5 reorderPoint: 10.
   i5 lotNumber: 32.
   i6 lotNumber: 14.
   i6 buyPrice: 32.
   i6 sellPrice: 36.
   i6 quantity: 99.
   i6 reorderPoint: 10.
</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	supplier:= nil.
	inventory := nil.
	itemList := OrderedCollection new.

	^self</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i5:">i5: anObject
	i5 := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i5">i5
	^i5</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">setUp
	"creates test objects"

	i1 := Item named: 'Video Game' sku:'89X999'.
	i2 := Item named: 'TV' sku: '99Z837'.
	i3 := Item named: 'VCR' sku: '54Y3632'.
	i4 := Item named: 'PC' sku: '01P6373'.
	i5 := Item named: 'Laptop' sku: '11F4732'.</body>

<body package="SupplyChain" selector="testShipmentArrived">testShipmentArrived
	"Tests the shipment arrived function"

	| r inv list|
	r := Retailer new.
	inv := Invoice new.
	list := OrderedCollection new.
	inv itemList add: i1.
	inv itemList add: i2.
	list add: inv.
	r shipmentArrived: list.
	self assert: (r inventory items size = 2).</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	i1 := nil.
	i2 := nil.
	i3 := nil.
	i4 := nil.
	i5 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.OrderTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.OrderTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="order">order
	^order</body>

<body package="SupplyChain" selector="order:">order: anObject
	order := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.OrderTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testAdd">testAdd
	order add: 'D'.
	self	assert: (order contains: 'D').</body>

<body package="SupplyChain" selector="testRemove">testRemove
	order add: 'D'.
	order remove: 'D'.
	self	deny: (order contains: 'D').</body>

<body package="SupplyChain" selector="setUp">setUp
	|col|
	col := OrderedCollection new.
	col add: 'A'.
	col add: 'B'.
	col add: 'C'.
	order with: col atHighPriority: true by: nil.
	^self.</body>

<body package="SupplyChain" selector="testSetPriority">testSetPriority
	order setPriority: false.
	self deny: (order isHighPriority).
	order setPriority: true.
	self assert: (order isHighPriority).</body>

<body package="SupplyChain" selector="testWithAtHighPriorityBy">testWithAtHighPriorityBy
	|col|
	col := OrderedCollection new.
	col add: 1; add:2; add:3.
	order with: col atHighPriority: false by: nil.
	self assert: ((order items) = col) &amp; ((order priority) = false) &amp; ((order retailer) = nil).
	order := Order new.</body>

<body package="SupplyChain" selector="testIsHighPriority">testIsHighPriority
	order setPriority: true.
	self assert: (order isHighPriority).
	order setPriority: false.
	self deny: (order isHighPriority).</body>

<body package="SupplyChain" selector="testContains">testContains
	order add: 'D'.
	self assert: (order contains: 'D').
	order remove: 'D'.
	self deny: (order contains: 'D').</body>
</methods>

<methods>
<class-id>SupplyChain.OrderTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	order := Order new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerEditItemDialog class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Retailer Edit Item GUI' 
			#bounds: #(#{Graphics.Rectangle} 640 512 868 740 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 203 ) 
					#name: #RetailerGUI 
					#label: 'Retailer GUI' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 12 5 ) 
					#name: #itemNameLabel 
					#label: 'Name' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 14 48 ) 
					#name: #buyPrice 
					#label: 'Buy Price:' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 73 48 ) 
					#name: #moneyBuyPrice 
					#label: '$00.00' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 14 75 ) 
					#name: #sellPrice 
					#label: 'Sell Price:' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 102 73 201 96 ) 
					#name: #sellPrice 
					#model: #sellPrice 
					#type: #number ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 14 109 ) 
					#name: #reorderPoint 
					#label: 'Reorder Point:' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 102 107 201 130 ) 
					#name: #reorderPoint 
					#model: #reorderPoint 
					#type: #number ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 8 159 89 182 ) 
					#name: #acceptButton 
					#model: #accept 
					#label: 'Done' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 130 157 211 182 ) 
					#name: #cancel 
					#model: #cancel 
					#label: 'Cancel' 
					#defaultable: true ) 
				#(#{UI.InputFieldSpec} 
					#layout: #(#{Graphics.Rectangle} 48 6 215 29 ) 
					#name: #nameInputField 
					#model: #nameAspect ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 11 27 ) 
					#name: #skuLabel 
					#label: 'SKU' ) 
				#(#{UI.InputFieldSpec} 
					#layout: #(#{Graphics.Rectangle} 48 29 214 49 ) 
					#name: #skuField 
					#model: #skuAspect 
					#isReadOnly: false ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerEditItemDialog class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="showEditItem:">showEditItem: anItem
	| wnd item |
	item := anItem.
	wnd := self new.
	wnd model: item.
	^wnd open.</body>

<body package="SupplyChain" selector="showNewItem">showNewItem
	| wnd item |
	item := Item new.
	wnd := self new.
	wnd model: item.
	^(wnd open
		ifTrue: [ ^item ]
		ifFalse: [ ^nil ]
	)</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerEditItemDialog</class-id> <category>aspects</category>

<body package="SupplyChain" selector="nameAspect">nameAspect
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^nameAspect isNil
		ifTrue:
			[nameAspect := String new asValue]
		ifFalse:
			[nameAspect]</body>

<body package="SupplyChain" selector="skuAspect">skuAspect
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^skuAspect isNil
		ifTrue:
			[skuAspect := String new asValue]
		ifFalse:
			[skuAspect]</body>

<body package="SupplyChain" selector="reorderPoint">reorderPoint
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^reorderPoint isNil
		ifTrue:
			[reorderPoint := 0 asValue]
		ifFalse:
			[reorderPoint]</body>

<body package="SupplyChain" selector="sellPrice">sellPrice
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^sellPrice isNil
		ifTrue:
			[sellPrice := 0 asValue]
		ifFalse:
			[sellPrice]</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerEditItemDialog</class-id> <category>accessing</category>

<body package="SupplyChain" selector="model:">model: anItem
	item := anItem.
	self changed: #name.
	self initialize.
	^self.</body>

<body package="SupplyChain" selector="item:">item: anItem
	self model: anItem.
	^self.</body>

<body package="SupplyChain" selector="item">item
	^item</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerEditItemDialog</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."
	super initialize.
	item isNil
		ifTrue: [item := Item new].
	
	nameAspect := (UI.AspectAdaptor subject: item) forAspect: #name.
	sellPrice := (UI.AspectAdaptor subject: item) forAspect: #sellPrice.
	reorderPoint := (UI.AspectAdaptor subject: item) forAspect: #reorderPoint.
	skuAspect := (UI.AspectAdaptor subject: item) forAspect: #sku.
	
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Outstanding Invoices' 
			#bounds: #(#{Graphics.Rectangle} 640 512 881 794 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 260 ) 
					#name: #Label1 
					#label: 'Supplier GUI' ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 36 35 203 198 ) 
					#name: #invoiceList 
					#model: #invoiceList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 36 12 ) 
					#name: #outstandingInvoice 
					#label: 'Outstanding Invoices' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 28 220 109 243 ) 
					#name: #fillInvoice 
					#model: #fillInvoice 
					#label: 'Fill Invoice' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 131 220 212 243 ) 
					#name: #done 
					#model: #accept 
					#label: 'Done' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog</class-id> <category>aspects</category>

<body package="SupplyChain" selector="invoiceList">invoiceList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^invoiceList isNil
		ifTrue:
			[invoiceList := SelectionInList new]
		ifFalse:
			[invoiceList]</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog</class-id> <category>accessing</category>

<body package="SupplyChain" selector="model">model

	^model</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog</class-id> <category>actions</category>

<body package="SupplyChain" selector="fillInvoice">fillInvoice

	"This stub method was generated by UIDefiner"

	^self</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierOutstandingInvoicesDialog</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	
	   "now we set up the list box for inventory.  We set the model of the list box to be a selectable item"
    
    invoiceList:= SelectionInList new.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.Item class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="named:sku:">named: anItemName sku: aCode
	"Creates a new Item object instance. This constructor should set appropriate values (name and sku) of the instance."
	
	| newItem |
	newItem := Item new.
	newItem name: anItemName.
	newItem sku: aCode.
	newItem quantity: 0.
	^newItem.</body>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Item</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	name := nil.
	buyPrice := 0.0.
	sellPrice := 0.0.
	sku := nil.
	quantity := 0.
	reorderPoint := 0.
	dateRecieved := Date today.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>accessing</category>

<body package="SupplyChain" selector="lotNumber">lotNumber
	^lotNumber.</body>

<body package="SupplyChain" selector="sellPrice:">sellPrice: anObject
	sellPrice := anObject</body>

<body package="SupplyChain" selector="dateRecieved:">dateRecieved: anObject
	dateRecieved := anObject</body>

<body package="SupplyChain" selector="reorderPoint">reorderPoint
	^reorderPoint</body>

<body package="SupplyChain" selector="lotNumber:">lotNumber: aNumber
	lotNumber:= aNumber.</body>

<body package="SupplyChain" selector="buyPrice:">buyPrice: anObject
	buyPrice := anObject</body>

<body package="SupplyChain" selector="quantity:">quantity: anObject
	quantity := anObject</body>

<body package="SupplyChain" selector="buyPrice">buyPrice
	^buyPrice</body>

<body package="SupplyChain" selector="sellPrice">sellPrice
	^sellPrice</body>

<body package="SupplyChain" selector="name:">name: anObject
	name := anObject</body>

<body package="SupplyChain" selector="sku:">sku: anObject
	sku := anObject</body>

<body package="SupplyChain" selector="quantity">quantity
	^quantity</body>

<body package="SupplyChain" selector="reorderPoint:">reorderPoint: anObject
	reorderPoint := anObject</body>

<body package="SupplyChain" selector="dateRecieved">dateRecieved
	^dateRecieved</body>

<body package="SupplyChain" selector="name">name
	^name</body>

<body package="SupplyChain" selector="sku">sku
	^sku</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>changing</category>

<body package="SupplyChain" selector="restockItem:">restockItem: anItem
	"Adds to the local inventory"

	quantity := quantity + anItem quantity</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>required</category>

<body package="SupplyChain" selector="itemValue">itemValue
	"Returns the value of this item computed as quantity * buy Price"
	^((self quantity) * (self buyPrice)).</body>

<body package="SupplyChain" selector="needsReorder">needsReorder
	"Returns true if the quantity is less than reorderPoint, false otherwise"

	^((self quantity) &lt; (self reorderPoint)).</body>

<body package="SupplyChain" selector="profit">profit
	"Returns the difference between the sell and buy price."
	
	^((self sellPrice) - (self buyPrice)).</body>

<body package="SupplyChain" selector="printString">printString
	"Returns a string rep of the item in format ''quantity name sku "
	^(((self quantity) printString),' ',(self name),' ',(self sku)).</body>

<body package="SupplyChain" selector="potentialProfit">potentialProfit
	"Returns the profit multiplied by the quantity"
	
	^(((self quantity) * (self sellPrice)) - ((self quantity) * (self buyPrice))).</body>
</methods>


<methods>
<class-id>SupplyChain.CCSTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="l1:">l1: anObject
	l1:= anObject.</body>

<body package="SupplyChain" selector="s1">s1
	^s1.</body>

<body package="SupplyChain" selector="ccs:">ccs: anObject
	ccs := anObject</body>

<body package="SupplyChain" selector="it2">it2
	^it2.</body>

<body package="SupplyChain" selector="it3:">it3: anObject
	it3:= anObject.</body>

<body package="SupplyChain" selector="ccs">ccs
	^ccs</body>

<body package="SupplyChain" selector="it4:">it4: anObject
	it4:= anObject.</body>

<body package="SupplyChain" selector="it1">it1
	^it1.</body>

<body package="SupplyChain" selector="it3">it3
	^it3.</body>

<body package="SupplyChain" selector="it1:">it1: anObject
	it1:= anObject.</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1:= anObject.</body>

<body package="SupplyChain" selector="i1">i1
	^i1.</body>

<body package="SupplyChain" selector="it4">it4
	^it4.</body>

<body package="SupplyChain" selector="r1:">r1: anObject
	r1:= anObject.</body>

<body package="SupplyChain" selector="it2:">it2: anObject
	it2:= anObject.</body>

<body package="SupplyChain" selector="r1">r1
	^r1.</body>

<body package="SupplyChain" selector="l1">l1
	^l1.</body>

<body package="SupplyChain" selector="s1:">s1: anObject
	s1:= anObject.</body>
</methods>

<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testRemoveRetailer">testRemoveRetailer
	ccs addRetailer: r1.
	ccs removeRetailer: r1.
	self deny: (ccs retailers includes: r1).</body>

<body package="SupplyChain" selector="testRemoveSupplier">testRemoveSupplier
	ccs addSupplier: s1.
	ccs removeSupplier: s1.
	self deny: (ccs suppliers includes: s1).</body>

<body package="SupplyChain" selector="testSave">testSave
	self addAllItems.
	ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs save.
	ccs load.
	self assert: (((ccs suppliers at: 1) name) = s1 name).
	self assert: (((ccs retailers at: 1) location) = r1 location).</body>

<body package="SupplyChain" selector="testLoad">testLoad
	ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs save.
	ccs load.
	self assert: (((ccs suppliers at: 1) name) = s1 name).
	self assert: (((ccs retailers at: 1) location) = r1 location).</body>

<body package="SupplyChain" selector="setUp">setUp
	r1 := Retailer new.
	r1 location: 'Home Depot'.
	r1 number: '1'.
	r2 := Retailer new.
	r1 location: 'Home Depot'.
	r1 number: '2'.
	s1 := Supplier new.
	s1 name: 'Super People'.
	s2 := Supplier new.
	s2 name: 'Less So'.
	i1 := Inventory new.
	i2 := Inventory new.
	l1 := Lot new.
	l2 := Lot new.
  	it1 := Item named: 'Video Game' sku:'89X999'.
  	it2 := Item named: 'TV' sku: '99Z837'.
  	it3 := Item named: 'VCR' sku: '54Y3632'.
  	it4 := Item named: 'PC' sku: '01P6373'.
	^self.</body>

<body package="SupplyChain" selector="testDeepCopy">testDeepCopy
	|copy|
	copy := ccs deepCopy.
	self assert: (ccs retailers = copy retailers).
	self assert: (ccs suppliers = copy suppliers).</body>

<body package="SupplyChain" selector="testAddRetailer">testAddRetailer
	ccs addRetailer: r1.
	self assert: (ccs retailers includes: r1).</body>

<body package="SupplyChain" selector="testHandleOrder">testHandleOrder
	|order items|
	order := Order new.
	items := OrderedCollection new.
	items add: it1.
	items add: it2.
	order items: items.
	order retailer: r1.
	self addAllItems.
      ccs addSupplier: s1.
	ccs addRetailer: r1.
	ccs handleOrder: order.
	self assert: (((r1 orderedItemsList at: 1) printString) = (it2 printString)).
	self assert: (((r1 orderedItemsList at: 2) printString) = (it1 printString)).</body>

<body package="SupplyChain" selector="testAddSupplier">testAddSupplier
	ccs addSupplier: s1.
	self assert: (ccs suppliers includes: s1).</body>
</methods>

<methods>
<class-id>SupplyChain.CCSTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	ccs := CCS new.
	r1 := nil.
	r2 := nil.
	s1 := nil.
	s2 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventories and lots"
   i1 addItem: it1.
   i1 addItem: it2.
   l1 addItem: it1.
   l1 addItem: it2.
   i2 addItem: it3.
   i2 addItem: it4.
   l2 addItem: it3.
   l2 addItem: it4.
   s1 inventory: i1.
   s1 lots: l1.
   s2 inventory: i2.
   s2 lots: l2.</body>
</methods>


<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testCheapestItem">testCheapestItem
	"Tests that the cheapest item (i1) is selected to sell"

	| soldItem |
	soldItem := retailer sellItem: i1.
	self assert: (soldItem == i1).</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	| inventory |
	inventory := Inventory new.
	i1 := Item named: 'Taco' sku: '123456'.
	i1 quantity: 10.
	i1 buyPrice: 8.
	i1 dateRecieved: (Date newDay: 4 monthNumber: 6 year: 2008).
	inventory addItem: i1.
	i2 := Item named: 'Taco' sku: '123456'.
	i2 quantity: 10.
	i2 buyPrice: 20.
	i2 dateRecieved: (Date newDay: 5 monthNumber: 7 year: 2008).
	inventory addItem: i2.
	i3 := Item named: 'Taco' sku: '123456'.
	i3 quantity: 10.
	i3 buyPrice: 10.
	i3 dateRecieved: (Date newDay: 10 monthNumber: 2 year: 2008).
	inventory addItem: i3.
	i4 := Item named: 'Taco' sku: '123456'.
	i4 quantity: 10.
	i4 buyPrice: 11.
	i4 dateRecieved: (Date newDay: 1 monthNumber: 10 year: 2008).
	inventory addItem: i4.
	
	retailer := Retailer new.
	retailer inventory: inventory.
	retailer sellPolicy: CheapestItemFirstPolicy new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	" *** This method was defined by SupplyChain.Policy as a subclass responsibility.
	Replace its body with a proper implementation. *** "

	| expensive items |
	"pick the items with this SKU"
	"SELECT * INTO item FROM inventory WHERE NOT EXISTS (SELECT * INTO i FROM inventory WHERE (i != item) AND (item.sellPrice &gt; i.sellPrice))"
	items := self inventory items select: [ :i | i sku = anSku ].
	expensive := items first.
	items do:
		[ :item |
		(item buyPrice &gt; expensive buyPrice)
			ifTrue: [ expensive := item. ]
		].
	^expensive.</body>
</methods>


<methods>
<class-id>SupplyChain.CCSAppModel class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'CCS Main GUI' 
			#bounds: #(#{Graphics.Rectangle} 640 512 1148 925 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 4 391 ) 
					#name: #CCSMainGUI 
					#label: 'CCS Main GUI' ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 11 58 201 264 ) 
					#name: #supplierList 
					#model: #supplierList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 13 272 94 295 ) 
					#name: #addSupplier 
					#model: #addSupplier 
					#label: 'Add Supplier' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 120 272 201 295 ) 
					#name: #deleteSupplier 
					#model: #deleteSupplier 
					#label: 'Delete Supplier' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 218 179 298 203 ) 
					#name: #load 
					#model: #load 
					#label: 'Load' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 219 212 300 235 ) 
					#name: #save 
					#model: #save 
					#label: 'Save ' 
					#defaultable: true ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 313 59 503 264 ) 
					#name: #retailerList 
					#model: #retailerList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 422 273 503 295 ) 
					#name: #deleteRetailer 
					#model: #deleteRetailer 
					#label: 'Delete Retailer' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 217 149 298 172 ) 
					#name: #viewReport 
					#model: #viewReport 
					#label: 'View Reports' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 14 32 ) 
					#name: #SupplierList 
					#label: 'Supplier List' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 314 33 ) 
					#name: #RetailerList 
					#label: 'Retailer List' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 315 273 396 295 ) 
					#name: #addRetailer 
					#model: #addRetailer 
					#label: 'Add Retailer' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 62 309 143 332 ) 
					#name: #supplierGUI 
					#model: #supplierGUI 
					#label: 'Open Supplier' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 369 310 450 333 ) 
					#name: #retailerGUI 
					#model: #retailerGUI 
					#label: 'Open Retailer' 
					#defaultable: true ) ) ) )</body>
</methods>


<methods>
<class-id>SupplyChain.CCSAppModel</class-id> <category>aspects</category>

<body package="SupplyChain" selector="supplierList">supplierList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^supplierList isNil
		ifTrue:
			[supplierList := SelectionInList new]
		ifFalse:
			[supplierList]</body>

<body package="SupplyChain" selector="retailerList">retailerList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^retailerList isNil
		ifTrue:
			[retailerList := SelectionInList new]
		ifFalse:
			[retailerList]</body>
</methods>

<methods>
<class-id>SupplyChain.CCSAppModel</class-id> <category>actions</category>

<body package="SupplyChain" selector="retailerGUI">retailerGUI
	"Opens the gui for the selected retailer"
	|gui|
	retailerList selection notNil ifTrue:[
		gui := RetailerAppModel new.
		gui retailer: retailerList selection.
		gui open.
		"get data back."
		ccs changed: #retailers.].
	^self</body>

<body package="SupplyChain" selector="deleteRetailer">deleteRetailer
	"Deletes the selected retailer from the list of retailers"
	retailerList selection notNil ifTrue:[(ccs retailers) remove: (retailerList selection)].
	ccs changed: #retailers.
	^self</body>

<body package="SupplyChain" selector="viewReport">viewReport
	"Allows the user to view the three reports"
	| answer report name newItem|
	answer := Dialog choose: 'Which report would you like to view?'
	                   fromList: #('Price Volatility' 'Emergency Order' 'Supplier Quantity')
	                   values: #(#price #order #quantity)
                         lines: 3
                         cancel: [nil].
	answer isNil ifFalse:[
		answer = #quantity ifTrue:[ 
			report := SupplierQuantityReport new.
			report suppliers: ccs suppliers.
			report retailers: ccs retailers.
			report open.].
		answer = #order ifTrue:[ 
			report := EmergencyOrderReport new.
			report orders: ccs allOrders.
			report open.].
		answer = #price ifTrue:[
			report := ItemPriceVoltilityReport new.
			report orders: ccs allOrders.
			name := Dialog request: 'What is the name of the item you are looking for?'
                      initialAnswer: ''.
			newItem := Item named: name sku: ''.
			report item: newItem.
			report open.].
		].
	^self</body>

<body package="SupplyChain" selector="addRetailer">addRetailer
	"Adds a retailer to the list of retailers"
	|t1 t2 t3 t4|

	t2 := Dialog request: 'Retailer name' initialAnswer: ' '.
	(t2 = '') ifFalse:[
		t3 := Dialog request: 'Retailer location' initialAnswer: ' '.
			(t3= '') ifFalse:[
				t4 := Dialog request: 'Retailer number' initialAnswer: ' '.
					(t4 = '') ifFalse:[
						t1 := Retailer new.
						t1 name: t2.
						t1 location: t3.
						t1 number: t4.
						ccs addRetailer: t1.
						ccs changed: #retailers.].].].

	^self.</body>

<body package="SupplyChain" selector="addSupplier">addSupplier
	"Adds a supplier to the list of suppliers"
	|t1 t2 t3 t4|

	t2 := Dialog request: 'Supplier name' initialAnswer: ' '.
	(t2 = '') ifFalse:[
		t3 := Dialog request: 'Supplier location' initialAnswer: ' '.
			(t3= '') ifFalse:[
				t4 := Dialog request: 'Supplier number' initialAnswer: ' '.
					(t4 = '') ifFalse:[
						t1 := Supplier new.
						t1 name: t2.
						t1 location: t3.
						t1 number: t4.
						ccs addSupplier: t1.
						ccs changed: #suppliers.].].].

	

	^self.</body>

<body package="SupplyChain" selector="load">load
	"Load a previous state"
	|boss filename array newCCS|
	filename := Dialog requestFileName: 'Open CCS'.
	(filename = '') ifFalse:[
		boss := BinaryObjectStorage onOldNoScan: filename asFilename readStream.
		[array := boss contents] ensure: [boss close].
		newCCS := array at: 1.
		self updateWith: newCCS.
		ccs changed: #suppliers.
		ccs changed: #retailers.
	].
	^self.</body>

<body package="SupplyChain" selector="save">save
	"Save the current CCS"
	|boss filename newCCS|
	newCCS := ccs deepCopy.
	filename := Dialog requestFileName: 'Open CCS'.
	(filename = '') ifFalse:[
		boss := BinaryObjectStorage onNew: filename asFilename writeStream.
		[boss nextPut: newCCS ] ensure: [boss close].
	].
	^self.</body>

<body package="SupplyChain" selector="deleteSupplier">deleteSupplier
	"Deletes the selected supplier from the list of suppliers"
	supplierList selection notNil ifTrue:[(ccs suppliers) remove: (supplierList selection)].
	ccs changed: #suppliers.
	^self</body>

<body package="SupplyChain" selector="supplierGUI">supplierGUI
	"Opens the gui for the selected supplier"
	|gui|
	supplierList selection notNil ifTrue:[
		gui := SupplierAppModel new.
		gui model: supplierList selection.
		gui open.
		"get data back."
		ccs changed: #suppliers.].
	^self</body>

<body package="SupplyChain" selector="updateWith:">updateWith: aCCS
	"Used with BOSS loading to update a newly loaded class instance"
	ccs retailers size timesRepeat: [ ccs retailers removeFirst ].
	ccs suppliers size timesRepeat: [ ccs suppliers removeFirst ].
	aCCS retailers do: [ :r | ccs addRetailer: r.].
	aCCS suppliers do: [ :s | ccs addSupplier: s.].
	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.CCSAppModel</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	super initialize.
	ccs := CCS new.
	(supplierList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: ccs sendsUpdates: true) forAspect: #suppliers).
	(retailerList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: ccs sendsUpdates: true) forAspect: #retailers).
	^self.</body>
</methods>


<methods>
<class-id>SupplyChain.ItemPriceVoltilityReport class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 
			#(#{Kernel.UserMessage} 
				#key: #EasyChart2 
				#defaultString: 'Supplier Quantity Report' 
				#catalogID: #BGOK ) 
			#min: #(#{Core.Point} 20 20 ) 
			#bounds: #(#{Graphics.Rectangle} 640 512 905 703 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.ChartViewSpec} 
					#layout: #(#{Graphics.LayoutFrame} 5 0 5 0 -5 1 -5 1 ) 
					#model: #data 
					#chartType: #BG_LineChartView 
					#dataSeries: 
					#(#{UI.ChartDataSpec} 
						#series: #(
							#(#{UI.ChartDataSetSpec} 
								#name: 'Data1' ) 
							#(#{UI.ChartDataSetSpec} 
								#isData: false 
								#name: 'Labels' ) ) ) 
					#yAxis: 
					#(#{UI.ChartingValueAxisSpec} 
						#scale: 
						#(#{UI.ChartingScaleSpec} 
							#invert: true ) ) ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.ItemPriceVoltilityReport class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize.</body>
</methods>


<methods>
<class-id>SupplyChain.ItemPriceVoltilityReport</class-id> <category>aspects</category>

<body package="SupplyChain" selector="data">data
	" Test information is commented out below the temp variable assignments	"
	| outer xValue inner yValue  |
	" i1 i2 i3 i4 i5 i6 i7 i8 o1 o2 o3 o4 o5 |

   	i1 := Item named: 'Video Game' sku:'89X999'.
   	i2 := Item named: 'TV' sku: '99Z837'.
   	i3 := Item named: 'VCR' sku: '54Y3632'.
   	i4 := Item named: 'PC' sku: '01P6373'.
   	i5 := Item named: 'Laptop' sku: '11F4732'.
   	i6 := Item named: 'TV' sku: '99Z837'.
   	i7 := Item named: 'TV' sku: '99Z837'.
   	i8 := Item named: 'TV' sku: '99Z837'.

	item:= i2.

	i2 buyPrice: 10.
	o1:= Order new.
	o1 add: i1.
	o1 add: i2.
	o1 add: i3.
	o1 add: i4.
	o1 add: i5.

	o2:= Order new.
	o2 add: i1.
	o2 add: i3.
	o2 add: i4.
	o2 add: i5.	

	i6 buyPrice: 6.
	o3:= Order new.
	o3 add: i6.
	o3 add: i5.
	o3 add: i4.
	

	i7 buyPrice: 15.
	o4:= Order new.
	o4 add: i3.
	o4 add: i7.

	i8 buyPrice: 14.
	o5:= Order new.
	o5 add: i5.
	o5 add: i4.
	o5 add: i3.
	o5 add: i8.
	o5 add: i1.

	
	
	orders add: o1.
	orders add: o2.
	orders add: o3.
	orders add: o4.
	orders add: o5.

"

	outer:= OrderedCollection new.
	xValue := 0.

	orders do: [:i |
		i items do: [:j |
			(j name = item name) ifTrue: [
				inner:= OrderedCollection new.
				yValue := j buyPrice.
				inner add: yValue.
			 	inner add: xValue.
			 	xValue := xValue + 1.
			 	outer add: inner.
			].
		].
	].
	
	^outer.</body>
</methods>

<methods>
<class-id>SupplyChain.ItemPriceVoltilityReport</class-id> <category>accessing</category>

<body package="SupplyChain" selector="item">item
	
	^item</body>

<body package="SupplyChain" selector="item:">item: anItem
	
	item := anItem.
	^self</body>

<body package="SupplyChain" selector="orders">orders

	^orders</body>

<body package="SupplyChain" selector="orders:">orders: anObject

	orders := anObject.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.ItemPriceVoltilityReport</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	orders := OrderedCollection new.
	item := Item new.
	
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.ItemTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>
</methods>

<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testItemNeedsReorder">testItemNeedsReorder
   i1 reorderPoint: 10.
   i1 quantity: 15.
   self deny: i1 needsReorder.
   i1 quantity: 9.
   self assert: i1 needsReorder.</body>

<body package="SupplyChain" selector="testItemPrintString">testItemPrintString
   i1 quantity: 10.
   self assert: i1 printString = '10 Video Game 89X999'.</body>

<body package="SupplyChain" selector="testItemPotentialProfit">testItemPotentialProfit
   i1 buyPrice: 10.
   i1 sellPrice: 35.
   i1 quantity: 3.
   self assert: i1 potentialProfit = 75.</body>

<body package="SupplyChain" selector="testItemProfit">testItemProfit
   i1 buyPrice: 10.
   i1 sellPrice: 35.
   self assert: i1 profit = 25.</body>

<body package="SupplyChain" selector="testItemValue">testItemValue
   self setUpPrices.
   self assert: i1 itemValue = 24.</body>

<body package="SupplyChain" selector="setUp">setUp
 "Create test objects.  This is called before every individual test"
	 i1 := Item named: 'Video Game' sku:'89X999'.</body>
</methods>

<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	i1 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierNewLotDialog class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Create New Lot' 
			#bounds: #(#{Graphics.Rectangle} 640 512 1061 808 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 27 55 167 246 ) 
					#name: #itemList 
					#model: #itemList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 27 29 ) 
					#name: #itemsList 
					#label: 'Items List' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 255 158 336 181 ) 
					#name: #addToLot 
					#model: #addToLotClick 
					#label: 'Add To Lot' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 183 69 ) 
					#name: #lotNumber 
					#label: 'Lot Number' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 246 68 377 91 ) 
					#name: #lotNum 
					#model: #lotNum 
					#type: #number ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 209 115 ) 
					#name: #price 
					#label: 'Price' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 246 114 378 136 ) 
					#name: #price 
					#model: #price 
					#type: #number ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 201 208 282 231 ) 
					#name: #done 
					#model: #accept 
					#label: 'Done' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 309 208 390 231 ) 
					#name: #cancel 
					#model: #cancel 
					#label: 'Cancel' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 273 ) 
					#name: #supplierGUI 
					#label: 'Supplier GUI' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 257 23 338 46 ) 
					#name: #addItem 
					#model: #addItemClick 
					#label: 'Add Item' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>aspects</category>

<body package="SupplyChain" selector="lotNum">lotNum
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^lotNum isNil
		ifTrue:
			[lotNum := 0 asValue]
		ifFalse:
			[lotNum]</body>

<body package="SupplyChain" selector="itemList">itemList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^itemList isNil
		ifTrue:
			[itemList := SelectionInList new]
		ifFalse:
			[itemList]</body>

<body package="SupplyChain" selector="tempLot">tempLot

	^tempLot</body>

<body package="SupplyChain" selector="tempLot:">tempLot: aLot

	tempLot:= aLot.

	^self.</body>

<body package="SupplyChain" selector="price">price
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^price isNil
		ifTrue:
			[price := 0 asValue]
		ifFalse:
			[price]</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory">inventory
	
	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: aInventory
	
	inventory:= aInventory.
	self changed: #items.
	^self</body>

<body package="SupplyChain" selector="model:">model: aInventory
	
	model:= aInventory.
	self changed: #items.
	^self</body>

<body package="SupplyChain" selector="model">model
	
	^model</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>actions</category>

<body package="SupplyChain" selector="addSupplier">addSupplier
	"Adds a supplier to the list of suppliers"
	|t1 t2 t3 |

	t2 := Dialog request: 'Item Name' initialAnswer: ' '.
	(t2 = '') ifFalse:[
		t3 := Dialog request: 'Item SKU' initialAnswer: ' '.
			(t3= '') ifFalse:[
						t1 := Item new.
						t1 name: t2.
						t1 sku: t3.
						(model inventory) add:t1.
						model changed: #inventory.].].
	^self.</body>

<body package="SupplyChain" selector="addItem">addItem
	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="addToLot">addToLot

	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="addToLotClick">addToLotClick

	"This stub method was generated by UIDefiner"

	| item	|

	
	itemList selection notNil ifTrue: [	"if there is something selected and the button is clicked....	"
		item:= itemList selection.  	"grab the selected item	"
		item lotNumber: lotNum.			"update the item with the current lot number selection		"
		item sellPrice: price.			" update the item with the current sell price		"
		model items add: item.
	].
	^self.</body>

<body package="SupplyChain" selector="addItemClick">addItemClick
	"Adds a supplier to the list of suppliers"
	|t1 t2 t3 |

	t2 := Dialog request: 'Item name' initialAnswer: ' '.
	(t2 = '') ifFalse:[
		t3 := Dialog request: 'Item Sku' initialAnswer: ' '.
			(t3= '') ifFalse:[
						t1 := Item new.
						t1 name: t2.
						t1 sku: t3.
						inventory items add: t1.
						inventory changed: #items.].].

	

	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	model:= Inventory new.
	inventory:= Inventory new.	"temp inventory"
	
	   "now we set up the list box for inventory.  We set the model of the list box to be a selectable item"
    
    (itemList:= SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (inventory) sendsUpdates: true)forAspect: #items).
	
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.LastItemFirstPolicy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.LastItemFirstPolicy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	" *** This method was defined by SupplyChain.Policy as a subclass responsibility.
	Replace its body with a proper implementation. *** "

	| last items |
	"pick the items with this SKU"
	"SELECT * INTO item FROM inventory WHERE NOT EXISTS (SELECT * INTO i FROM inventory WHERE (i != item) AND (item.sellPrice &gt; i.sellPrice))"
	items := self inventory items select: [ :i | i sku = anSku ].
	last := items first.
	items do:
		[ :item |
		(item dateRecieved &gt; last dateRecieved)
			ifTrue: [ last := item. ]
		].
	^last.</body>
</methods>


<methods>
<class-id>SupplyChain.InvoiceTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.InvoiceTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i5">i5
	
	^i5</body>

<body package="SupplyChain" selector="i3:">i3: anItem
	
	i3 := anItem.
	^self</body>

<body package="SupplyChain" selector="i3">i3
	
	^i3</body>

<body package="SupplyChain" selector="invoice:">invoice: anInvoice

	invoice := anInvoice.
	^self</body>

<body package="SupplyChain" selector="items:">items: someItems
	
	items := someItems.
	^self</body>

<body package="SupplyChain" selector="i4">i4
	
	^i4</body>

<body package="SupplyChain" selector="i2">i2
	
	^i2</body>

<body package="SupplyChain" selector="i5:">i5: anItem
	
	i5 := anItem.
	^self</body>

<body package="SupplyChain" selector="i1:">i1: anItem
	
	i1 := anItem.
	^self</body>

<body package="SupplyChain" selector="invoice">invoice

	^invoice</body>

<body package="SupplyChain" selector="i1">i1
	
	^i1</body>

<body package="SupplyChain" selector="items">items
	
	^items</body>

<body package="SupplyChain" selector="i2:">i2: anItem
	
	i2 := anItem.
	^self</body>

<body package="SupplyChain" selector="i4:">i4: anItem
	
	i4 := anItem.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.InvoiceTest</class-id> <category>running</category>

<body package="SupplyChain" selector="testGetInvoiceCost">testGetInvoiceCost

	self setUpPrices.
	invoice addItem: i1.
	invoice addItem: i2.
	invoice addItem: i3.
	invoice addItem: i4.
	invoice addItem: i5.
	self assert: (invoice getInvoiceCost = 86).
	^self</body>

<body package="SupplyChain" selector="testInvoice">testInvoice

	items:= OrderedCollection new.

	items add: i1.
	items add: i2.
	items add: i3.
	items add: i4.
	items add: i5.
	
	invoice itemList: items.
     
      self assert: (invoice itemList includes: i1).
      self assert: (invoice itemList includes: i2).
	
	^self</body>

<body package="SupplyChain" selector="testInvoiceAddItem">testInvoiceAddItem

	self assert: invoice itemList size = 0.
	invoice addItem: i1.
	self assert: invoice itemList size = 1.
	self assert: (invoice itemList includes: i1).
	invoice addItem: i2.
	self assert: invoice itemList size = 2.
	self assert: (invoice itemList includes: i2).
	^self</body>

<body package="SupplyChain" selector="testGetInvoiceValue">testGetInvoiceValue
	
	self setUpPrices.
	invoice addItem: i1.
	invoice addItem: i2.
	invoice addItem: i3.
	invoice addItem: i4.
	invoice addItem: i5.
	self assert: (invoice getInvoiceValue = 634).
	^self</body>

<body package="SupplyChain" selector="setUp">setUp
   "Create test objects.  This is called before every individual test"

   invoice := Invoice new.
   i1 := Item named: 'Video Game' sku:'89X999'.
   i2 := Item named: 'TV' sku: '99Z837'.
   i3 := Item named: 'VCR' sku: '54Y3632'.
   i4 := Item named: 'PC' sku: '01P6373'.
   i5 := Item named: 'Laptop' sku: '11F4732'.
   

   ^self</body>
</methods>

<methods>
<class-id>SupplyChain.InvoiceTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="setUpPrices">setUpPrices

	self addAllItems.
	
	i1 buyPrice: 3.
	i1 sellPrice: 7.
	i1 quantity: 8.
	i1 reorderPoint: 9.

	i2 buyPrice: 22.
	i2 sellPrice: 36.
	i2 quantity: 7.
	i2 reorderPoint: 6. 

	i3 buyPrice: 18.
	i3 sellPrice: 40.
	i3 quantity: 3.
	i3 reorderPoint: 3.

	i4 buyPrice: 19.
	i4 sellPrice: 36.
	i4 quantity: 6.
	i4 reorderPoint: 7.

	i5 buyPrice: 24.
	i5 sellPrice: 36.
	i5 quantity: 12.
	i5 reorderPoint: 10.

	^self</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	items := OrderedCollection new.
	

	i1 := nil.
	i2 := nil.
	i3 := nil.
	i4 := nil.
	i5 := nil.
	^self</body>

<body package="SupplyChain" selector="addAllItems">addAllItems
   	"utility method to add all the items to the inventory"

  	items add: i1.
 	items add: i2.
 	items add: i3.
 	items add: i4.
   	items add: i5.

	^self</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierQuantityReport class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 
			#(#{Kernel.UserMessage} 
				#key: #EasyChart2 
				#defaultString: 'Supplier Quantity Report' 
				#catalogID: #BGOK ) 
			#min: #(#{Core.Point} 20 20 ) 
			#bounds: #(#{Graphics.Rectangle} 640 512 905 703 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.ChartViewSpec} 
					#layout: #(#{Graphics.LayoutFrame} 5 0 5 0 -5 1 -5 1 ) 
					#model: #data 
					#dataSeries: 
					#(#{UI.ChartDataSpec} 
						#series: #(
							#(#{UI.ChartDataSetSpec} 
								#name: 'Data1' ) 
							#(#{UI.ChartDataSetSpec} 
								#name: 'Data2' ) 
							#(#{UI.ChartDataSetSpec} 
								#isData: false 
								#name: 'Labels' ) ) ) ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierQuantityReport class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize.</body>
</methods>


<methods>
<class-id>SupplyChain.SupplierQuantityReport</class-id> <category>aspects</category>

<body package="SupplyChain" selector="data">data
	"This just formats the data properly for displaying on the chart"
	|outer inner "r1 r2 i1 i2 l1 l2 it1 it2 it3 it4"|
	"r1 := Retailer new.
	r1 name: 'Home Depot'.
	r1 number: '1'.
	r2 := Retailer new.
	r2 name: 'Lowes'.
	r2 number: '2'.
	i1 := Inventory new.
	l1 := Lot new.
	i2 := Inventory new.
	l2 := Lot new.
  	it1 := Item named: 'Video Game' sku:'89X999'.
	it1 quantity: 4.
  	it2 := Item named: 'TV' sku: '99Z837'.
	it2 quantity: 12.
  	it3 := Item named: 'VCR' sku: '54Y3632'.
	it3 quantity: 7.
  	it4 := Item named: 'PC' sku: '01P6373'.
	it4 quantity: 15.
	l1 addItem: it1.
	l2 addItem:it2.
	l1 addItem: it3.
	l2 addItem: it4.
	i1 addItem: it1.
	i2 addItem:it2.
	i1 addItem: it3.
	i2 addItem: it4.
	r1 inventory: i1.
	r2 inventory: i2.
	retailers add: r1.
	retailers add: r2."
	outer := OrderedCollection new.
	retailers do:[:i|
		inner := OrderedCollection new.
		(i inventory items) do:[:j|
			inner add: (j quantity).].
		(inner size = 0) ifTrue:[ inner add: 0. inner add: 0.].
		(inner size = 1) ifTrue:[ inner add: 0.].
		inner add: (i name).
		outer add: inner.].
	^outer.</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierQuantityReport</class-id> <category>accessing</category>

<body package="SupplyChain" selector="suppliers">suppliers
	^suppliers</body>

<body package="SupplyChain" selector="retailers">retailers
	^retailers</body>

<body package="SupplyChain" selector="retailers:">retailers: anObject
	retailers := anObject</body>

<body package="SupplyChain" selector="suppliers:">suppliers: anObject
	suppliers := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierQuantityReport</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	suppliers := OrderedCollection new.
	retailers := OrderedCollection new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.EarliestItemFirstPolicy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.EarliestItemFirstPolicy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	" *** This method was defined by SupplyChain.Policy as a subclass responsibility.
	Replace its body with a proper implementation. *** "

	| earliest items |
	"pick the items with this SKU"
	"SELECT * INTO item FROM inventory WHERE NOT EXISTS (SELECT * INTO i FROM inventory WHERE (i != item) AND (item.sellPrice &gt; i.sellPrice))"
	items := self inventory items select: [ :i | i sku = anSku ].
	earliest := items first.
	items do:
		[ :item |
		(item dateRecieved &lt; earliest dateRecieved)
			ifTrue: [ earliest := item. ]
		].
	^earliest.</body>
</methods>


<methods>
<class-id>SupplyChain.Retailer class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Retailer</class-id> <category>changing</category>

<body package="SupplyChain" selector="setPolicy:">setPolicy: aPolicy
	"Sets the sellPolicy of the store"

	self sellPolicy: aPolicy</body>

<body package="SupplyChain" selector="shipmentArrived:">shipmentArrived: anInvoiceList
	"Add to the list of items"

	anInvoiceList do:[ :i| i itemList do: [ :item |
		(inventory hasItem: item)
			ifFalse: [ inventory addItem: (Item named: (item name) sku: (item sku)) ].
			
			inventory restockItem: item.].].</body>
</methods>

<methods>
<class-id>SupplyChain.Retailer</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory:">inventory: anObject
	inventory := anObject</body>

<body package="SupplyChain" selector="ccs">ccs
	^ccs</body>

<body package="SupplyChain" selector="sellPolicy:">sellPolicy: anObject
	sellPolicy := anObject.
	sellPolicy inventory: inventory.</body>

<body package="SupplyChain" selector="hasItem:">hasItem: anItem
	"Tests if this retailer's inventory contains an item."
	
	^inventory items includes: anItem.</body>

<body package="SupplyChain" selector="lastOrderPlaced">lastOrderPlaced
	^lastOrderPlaced.</body>

<body package="SupplyChain" selector="number:">number: anObject
	number := anObject</body>

<body package="SupplyChain" selector="name">name
	^name.</body>

<body package="SupplyChain" selector="location">location
	^location</body>

<body package="SupplyChain" selector="lastOrderPlaced:">lastOrderPlaced: anOrder
	lastOrderPlaced := anOrder.
	^self.</body>

<body package="SupplyChain" selector="orderedItemsList">orderedItemsList
	"Gets a list of ordered items for this Retailer"

	^inventory items.</body>

<body package="SupplyChain" selector="sellPolicy">sellPolicy
	^sellPolicy</body>

<body package="SupplyChain" selector="inventory">inventory
	^inventory</body>

<body package="SupplyChain" selector="location:">location: anObject
	location := anObject</body>

<body package="SupplyChain" selector="number">number
	^number</body>

<body package="SupplyChain" selector="ccs:">ccs: anObject
	ccs := anObject</body>

<body package="SupplyChain" selector="name:">name: anObject
	name := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.Retailer</class-id> <category>printing</category>

<body package="SupplyChain" selector="printString">printString
	^(name,' ', location, ' ', number).</body>
</methods>

<methods>
<class-id>SupplyChain.Retailer</class-id> <category>controlling</category>

<body package="SupplyChain" selector="sellItem:">sellItem: anItem
	"Attempts to sell an item.
	Returns the item if the item is sold, nil if the item was not found."
	
	| item |
	
	^(self hasItem: anItem)
		ifTrue:
			[item := sellPolicy determineSellItem: (anItem sku).
			item quantity: (item quantity - 1).
			item needsReorder ifTrue: [self reorder: item].
			^item]
		ifFalse:
			[^nil]</body>

<body package="SupplyChain" selector="reorder:">reorder: anItem
	"Reorders an item from the CCS"
	
	| order |
	
	order := Order new.
	order add: anItem.
	order retailer: self.
	lastOrderPlaced := order.
	[
		Delay forSeconds: 4.
		ccs handleOrder: order.
	] fork.</body>
</methods>

<methods>
<class-id>SupplyChain.Retailer</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	location := 'Unknown'.
	number := 0.
	sellPolicy := CheapestItemFirstPolicy new.
	inventory := Inventory new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.Inventory class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.Inventory</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	items := SortedCollection new.
	items sortBlock:[:a :b | a name &lt; b name].
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Inventory</class-id> <category>accessing</category>

<body package="SupplyChain" selector="items">items
	^items</body>

<body package="SupplyChain" selector="hasItem:">hasItem: anItem
	"Tests if an item is in this inventory"

	^items contains: [ :i | i sku = anItem sku ]</body>

<body package="SupplyChain" selector="items:">items: anObject
	items := anObject</body>

<body package="SupplyChain" selector="getItems">getItems
	^items</body>

<body package="SupplyChain" selector="restockItem:">restockItem: anItem
	"Restocks an item"
	
	(self hasItem: anItem)
		ifFalse: [ self addItem: (Item named: (anItem name) sku: (anItem sku)) ].
	(self items detect: [ :i | i sku = anItem sku]) restockItem: anItem.</body>
</methods>

<methods>
<class-id>SupplyChain.Inventory</class-id> <category>required</category>

<body package="SupplyChain" selector="getInventoryCost">getInventoryCost
	"Returns the sum of all the item values"

	| sum |
	sum := 0.
	(self items) do:[:i | sum := sum + (i buyPrice).].
	^sum.</body>

<body package="SupplyChain" selector="printString">printString
	"Returns a string representation of the Inventory as: 'An Inventory of n items valued at x dollars' "

	|itemSum totalValue|
	itemSum := ((self items) size).
	totalValue := 0.
	(self items) do:[:i |
		totalValue := totalValue + ((i buyPrice) * (i quantity)).].
	^('An Inventory of ',(itemSum printString),' items valued at ',(totalValue printString),' dollars').</body>

<body package="SupplyChain" selector="removeItem:">removeItem: anItem
	"Removes an Item from the items collection"
	((self items) isEmpty) ifFalse:[
		((self items) includes: anItem) ifTrue:[
			(self items) remove: anItem.].].
	^self</body>

<body package="SupplyChain" selector="sortBlock:">sortBlock: aBlock
	"Change the sort order of the items"
	
	(self items) sortBlock: aBlock.
	(((self items) size) &gt; 0) ifTrue:[ (self items) reSort.].
	^self.</body>

<body package="SupplyChain" selector="addItem:">addItem: anItem
	"Adds an Item to the items collection"
	(self items) add: anItem.
	^self.</body>

<body package="SupplyChain" selector="potentialProfit">potentialProfit
	"Return the sum of all the individual item potentialProfits"

	| profits |
	profits := 0.0.
	(self items) do:[:i | profits := profits + (i potentialProfit).].
	^profits.</body>

<body package="SupplyChain" selector="getInventoryReport">getInventoryReport
	"Print a report"
	|profitSum output|
	profitSum := 0.
	output := (self printString).
	(self items) do:[:i |
		output := output, '\' withCRs, (i printString).
		profitSum := profitSum + (i potentialProfit)].
	output := output,'\' withCRs,('Total Inventory Potential Profit is ',(profitSum printString),' dollars').
	^output.</body>

<body package="SupplyChain" selector="inventoryValue">inventoryValue
	"Returns the sum of all the item values"

	| sum |
	sum := 0.
	(self items) do:[:i | sum := sum + (i itemValue).].
	^sum.</body>

<body package="SupplyChain" selector="getInventoryValue">getInventoryValue
	"Returns the sum of all the item values"

	| sum |
	sum := 0.
	(self items) do:[:i | sum := sum + (i itemValue).].
	^sum.</body>

<body package="SupplyChain" selector="printInventoryReport">printInventoryReport
	"Print a report"
	|profitSum|
	profitSum := 0.
	Transcript show: (self printString).
	(self items) do:[:i |
		Transcript cr.
		Transcript show: (i printString).
		profitSum := profitSum + (i potentialProfit)].
	Transcript cr.
	Transcript show: ('Total Inventory Potential Profit is ',(profitSum printString),' dollars').
	^self.</body>

<body package="SupplyChain" selector="getReorderItems">getReorderItems
	"Return a collection of all the items in the inventory that need to be reordered"

	| reorderItems |
	reorderItems := OrderedCollection new.
	(self items) do:[:i | (i needsReorder) ifTrue:[
			reorderItems add: i.].].
	^reorderItems.</body>
</methods>


<methods>
<class-id>SupplyChain.EarliestItemFirstPolicyTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.EarliestItemFirstPolicyTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="retailer:">retailer: anObject
	retailer := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="retailer">retailer
	^retailer</body>
</methods>

<methods>
<class-id>SupplyChain.EarliestItemFirstPolicyTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testEarliestItem">testEarliestItem
	"Tests that the earliest item (i3) is selected to sell"

	| soldItem |
	soldItem := retailer sellItem: i1.
	self assert: (soldItem == i3).</body>
</methods>

<methods>
<class-id>SupplyChain.EarliestItemFirstPolicyTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	| inventory |
	inventory := Inventory new.
	i1 := Item named: 'Taco' sku: '123456'.
	i1 quantity: 10.
	i1 buyPrice: 8.
	i1 dateRecieved: (Date newDay: 4 monthNumber: 6 year: 2008).
	inventory addItem: i1.
	i2 := Item named: 'Taco' sku: '123456'.
	i2 quantity: 10.
	i2 buyPrice: 20.
	i2 dateRecieved: (Date newDay: 5 monthNumber: 7 year: 2008).
	inventory addItem: i2.
	i3 := Item named: 'Taco' sku: '123456'.
	i3 quantity: 10.
	i3 buyPrice: 10.
	i3 dateRecieved: (Date newDay: 10 monthNumber: 2 year: 2008).
	inventory addItem: i3.
	i4 := Item named: 'Taco' sku: '123456'.
	i4 quantity: 10.
	i4 buyPrice: 11.
	i4 dateRecieved: (Date newDay: 1 monthNumber: 10 year: 2008).
	inventory addItem: i4.
	
	retailer := Retailer new.
	retailer inventory: inventory.
	retailer sellPolicy: EarliestItemFirstPolicy new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicyTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicyTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="retailer">retailer
	^retailer</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="retailer:">retailer: anObject
	retailer := anObject</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>
</methods>

<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicyTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testExpensiveItem">testExpensiveItem
	"Tests that the most expensive item (i2) is selected to sell"

	| soldItem |
	soldItem := retailer sellItem: i1.
	self assert: (soldItem == i2).</body>
</methods>

<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicyTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	| inventory |
	inventory := Inventory new.
	i1 := Item named: 'Taco' sku: '123456'.
	i1 quantity: 10.
	i1 buyPrice: 8.
	i1 dateRecieved: (Date newDay: 4 monthNumber: 6 year: 2008).
	inventory addItem: i1.
	i2 := Item named: 'Taco' sku: '123456'.
	i2 quantity: 10.
	i2 buyPrice: 20.
	i2 dateRecieved: (Date newDay: 5 monthNumber: 7 year: 2008).
	inventory addItem: i2.
	i3 := Item named: 'Taco' sku: '123456'.
	i3 quantity: 10.
	i3 buyPrice: 10.
	i3 dateRecieved: (Date newDay: 10 monthNumber: 2 year: 2008).
	inventory addItem: i3.
	i4 := Item named: 'Taco' sku: '123456'.
	i4 quantity: 10.
	i4 buyPrice: 11.
	i4 dateRecieved: (Date newDay: 1 monthNumber: 10 year: 2008).
	inventory addItem: i4.
	
	retailer := Retailer new.
	retailer inventory: inventory.
	retailer sellPolicy: ExpensiveItemFirstPolicy new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.LotTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>


<methods>
<class-id>SupplyChain.LotTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="lot">lot
	^lot</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject.
	^self</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject.
	^self</body>

<body package="SupplyChain" selector="i5:">i5: anItem
	i5 := anItem.
	^self</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject.
	^self</body>

<body package="SupplyChain" selector="i5">i5
	^i5</body>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject.
	^self</body>

<body package="SupplyChain" selector="lot:">lot: aLot
	lot := aLot.
	^self</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>
</methods>

<methods>
<class-id>SupplyChain.LotTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testAddItems">testAddItems
	"Tests the addItem functionality"
	
	self assert: lot size = 0.
	lot addItem: i1.
	self assert: lot size = 1.
	lot addItem: i2.
	self assert: lot size = 2.
	self deny: (lot contains: i3).
	lot addItem: i3.
	self assert: (lot contains: i3).
	self assert: lot size = 3.</body>

<body package="SupplyChain" selector="testNumber">testNumber
	| rval |
	rval := 5.
	lot number: rval.
	self assert: (lot number = rval)</body>

<body package="SupplyChain" selector="setUp">setUp
	"Creates the test objects"
	lot := Lot new.
	i1 := Item named: 'Video Game' sku:'89X999'.
	i2 := Item named: 'TV' sku: '99Z837'.
	i3 := Item named: 'VCR' sku: '54Y3632'.
	i4 := Item named: 'PC' sku: '01P6373'.
	i5 := Item named: 'Laptop' sku: '11F4732'.</body>
</methods>

<methods>
<class-id>SupplyChain.LotTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	i1 := nil.
	i2 := nil.
	i3 := nil.
	i4 := nil.
	i5 := nil.
	lot := nil.
	^self</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerAppModel class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Retailer GUI' 
			#bounds: #(#{Graphics.Rectangle} 640 512 1055 824 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 295 ) 
					#name: #retailerGUI 
					#label: 'SuperPOS v0.1' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 341 296 ) 
					#name: #retailerName 
					#label: 'Retailer Name' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 29 216 110 239 ) 
					#name: #edit 
					#model: #editButtonClick 
					#label: 'Edit Item' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 164 224 245 247 ) 
					#name: #sell 
					#model: #sellItemClick 
					#label: 'Sell Item' 
					#defaultable: true ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 96 266 152 ) 
					#name: #GroupBox2 ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 159 266 215 ) 
					#name: #GroupBox3 ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 160 101 ) 
					#name: #marketValue 
					#label: 'Total Market Value' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 122 ) 
					#name: #moneyMarket 
					#label: '$00.00' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 148 163 ) 
					#name: #inventoryCost 
					#label: 'Total Cost of Inventory' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 184 ) 
					#name: #moneyInv 
					#label: '$00.00' ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 32 266 88 ) 
					#name: #GroupBox1 ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 60 ) 
					#name: #moneyInventory 
					#label: '$00.00' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 152 37 ) 
					#name: #totalValue 
					#label: 'Total Inventory Value' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 162 279 259 302 ) 
					#name: #changeSellPolicy 
					#model: #changePolicyClick 
					#label: 'Change Sell Policy' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 282 5 ) 
					#name: #itemsOnOrder 
					#label: 'Items On Order' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 10 7 ) 
					#name: #currInventory 
					#label: 'Current Inventory' ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 9 30 131 214 ) 
					#name: #inventoryList 
					#model: #inventoryList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 281 30 403 214 ) 
					#name: #itemsOnOrderList 
					#model: #itemList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 30 243 111 266 ) 
					#name: #addItemButton 
					#model: #addButtonClick 
					#label: 'Add Item' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize.</body>

<body package="SupplyChain" selector="withRetailer:">withRetailer: aRetailer
	| this |
	this := super new initialize.
	this retailer: aRetailer.
	^this.</body>
</methods>


<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>aspects</category>

<body package="SupplyChain" selector="inventoryList">inventoryList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^inventoryList isNil
		ifTrue:
			[inventoryList := SelectionInList new]
		ifFalse:
			[inventoryList]</body>

<body package="SupplyChain" selector="itemList">itemList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^itemList isNil
		ifTrue:
			[itemList := SelectionInList new]
		ifFalse:
			[itemList]</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>accessing</category>

<body package="SupplyChain" selector="retailer">retailer
	^retailer.</body>

<body package="SupplyChain" selector="currentInventoryList">currentInventoryList
	^currentInventoryList</body>

<body package="SupplyChain" selector="retailer:">retailer: anObject
	retailer := anObject.
	(inventoryList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (retailer inventory) sendsUpdates: true) forAspect: #items).
	(itemList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: currentOrder sendsUpdates: true) forAspect: #items).
	^retailer.</body>

<body package="SupplyChain" selector="itemList:">itemList: anObject
	^itemList := anObject</body>

<body package="SupplyChain" selector="currentInventoryList:">currentInventoryList: anObject
	currentInventoryList := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>actions</category>

<body package="SupplyChain" selector="changePolicyClick">changePolicyClick
	"What happens when a user clicks the change policy"
	|dialog|
	dialog := RetailerSellPolicyDialog new.
	dialog policy: (self retailer sellPolicy class).
	(dialog open) ifTrue:[ (self retailer) sellPolicy: (dialog policy new).].
	^self.</body>

<body package="SupplyChain" selector="editButtonClick">editButtonClick
	"What happens when the user clicks the edit button"

	inventoryList selection notNil
		ifTrue:
			[ | item dialog |
			item := inventoryList selection.
			dialog := RetailerEditItemDialog new.
			dialog model: item.
			dialog open ifTrue:
				[ (retailer inventory) changed: #items.].
			].</body>

<body package="SupplyChain" selector="sellItemClick">sellItemClick
	"What happens when a user clicks the sell button"

	inventoryList selection notNil ifTrue:
	[	| item |
		item := inventoryList selection.
		retailer sellItem: item.
		(retailer inventory) changed: #items.
		(retailer lastOrderPlaced notNil) ifTrue:[
			currentOrder := retailer lastOrderPlaced.
			(itemList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: currentOrder sendsUpdates: true) forAspect: #items).
			retailer lastOrderPlaced changed: #items.
			Delay forSeconds: 5.
			currentOrder := OrderedCollection new.
			(itemList := SelectionInList new) listHolder:(UI.ValueHolder with: currentOrder).
		]
	]</body>

<body package="SupplyChain" selector="addButtonClick">addButtonClick
	| item |
	item := RetailerEditItemDialog showNewItem.
	
	item notNil ifTrue:
		[retailer inventory addItem: item.
		(retailer sellPolicy) inventory: (retailer inventory).
		(retailer inventory) changed: #items.].
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize the variables"

	super initialize.
	retailer isNil ifTrue:
		[ retailer := Retailer new].
	(inventoryList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (retailer inventory) sendsUpdates: true) forAspect: #items).
	currentOrder isNil ifTrue:
		[ currentOrder := Order new].
	(itemList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: currentOrder sendsUpdates: true) forAspect: #items).</body>
</methods>



</st-source>
